# -*- coding: utf-8 -*-

"""
Datetime: 2020/07/23
Author: Zhang Yafei
Description: 百度验证码识别 
"""
from aip import AipOcr

""" 你的 APPID AK SK """
APP_ID = '你的app_id'
API_KEY = 'app_key'
SECRET_KEY = 'secret_key'

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)


def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()


# image = get_file_content('images/mien.jpg')
image = get_file_content('images/segs.jpg')
""" 如果有可选参数 """
options = {}
options["detect_direction"] = "true"
""" 调用通用文字识别, 图片参数为本地图片 """
result = client.basicGeneral(image, options=options)
print(result['words_result'])

ret2 = client.basicAccurate(image, options=options)
print(result['words_result'])